<?php foreach($config as $name=>$vo): ?>

<?php // 文本数据 ?>
<?php if($vo['type'] === 'text'): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label}</label>
    <div class="col-sm-6">
        <input type="text" placeholder="{$vo.placeholder}" class="form-control" name="{$name}" value="{:template_cache(C('sid'),$name)}">
        <notempty name="vo.desc">
        <span class="help-block" style="margin-bottom:0px;">{$vo.desc}</span>
        </notempty>
    </div>
</div>
<?php endif; ?>

<?php // 多行文本 ?>
<?php if($vo['type'] === 'textarea'): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label}</label>
    <div class="col-sm-6">
        <textarea name="{$name}" placeholder="{$vo.placeholder}" class="form-control" rows="{$vo.rows|default=1}">{:template_cache(C('sid'),$name)}</textarea>
        <notempty name="vo.desc">
        <span class="help-block" style="margin-bottom:0px;">{$vo.desc}</span>
        </notempty>
    </div>
</div>
<?php endif; ?>

<?php // 填写ID ?>
<?php if($vo['type'] === 'article'): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label}</label>
    <div class="col-sm-6">
        <input type="text" placeholder="{$vo.placeholder}" class="form-control" name="{$name}_input" value="">
        <p class="help-block" id="{$name}_list">
        <?php $articleList = get_article_by_ids(template_cache(C('sid'),$name)); ?>
        <?php foreach($articleList as $key=>$vo): ?>
        <span class="tag">
            <input type="hidden" name="{$name}[]" value="{$vo.id}" />
            <span>{$vo.title|subTitle=15}</span>
            <a href="javascript:;" class="close">x</a>
        </span>
        <?php endforeach; ?>
        </p>
        <script>
            $('input[name={$name}_input]').blur(function() {
                var id = $(this).val();
                if(id.length < 1) {
                    showMessage('文章ID不能为空');
                    return false;
                }
                $.get('/article/getajax',{id:id},function(data) {
                    if(data.code == 200) {
                        var strcode = '<span class="article">' + 
                                      '<input type="hidden" name="{$name}[]" value="'+data.data.id+'" />' +
                                      '<span>' + data.data.title + '</span>' + 
                                      '<a href="javascript:;" class="close">x</a>' +
                                      '</span>';

                        $('#{$name}_list').append(strcode);
                    }else{
                        showMessage(data.message);
                    }
                },'json');
                $(this).val('');
            });
            $(document).on("click","#{$name}_list .close",function(){
                $(this).parent().remove();
            });
        </script>
    </div>
</div>
<?php endif; ?>

<?php // 标签 ?>
<?php if($vo['type'] === 'tags'): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label}</label>
    <div class="col-sm-6">
        <input type="text" placeholder="{$vo.placeholder}" class="form-control" name="{$name}_input" value="">
        <p class="help-block" id="{$name}_list">
        <?php $tagList = get_tags_by_ids(template_cache(C('sid'),$name)); ?>
        <?php foreach($tagList as $key=>$vo): ?>
        <span class="tag">
            <input type="hidden" name="{$name}[]" value="{$vo.id}" />
            <span>{$vo.nickname}</span>
            <a href="javascript:;" class="close">x</a>
        </span>
        <?php endforeach; ?>
        </p>
        <script>
            $('input[name={$name}_input]').blur(function() {
                var id = $(this).val();
                if(id.length < 1) {
                    showMessage('标签ID不能为空');
                    return false;
                }
                $.get('/tags/getajax',{id:id},function(data) {
                    if(data.code == 200) {
                        var strcode = '<span class="tag">' + 
                                      '<input type="hidden" name="{$name}[]" value="'+data.data.id+'" />' +
                                      '<span>' + data.data.title + '</span>' + 
                                      '<a href="javascript:;" class="close">x</a>' +
                                      '</span>';

                        $('#{$name}_list').append(strcode);
                    }else{
                        showMessage(data.message);
                    }
                },'json');
                $(this).val('');
            });
            $(document).on("click","#{$name}_list .close",function(){
                $(this).parent().remove();
            });
        </script>
    </div>
</div>
<?php endif; ?>

<?php // 填写ID ?>
<?php if($vo['type'] === 'slider'): ?>
<?php for($i=1;$i<=$vo['maxnum'];$i++): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label} {$i}</label>
    <div class="col-sm-6">
        <div class="col-sm-3">
            {:W('Image/upload',array('data'=>array('name'=>$name.'['.$i.']','maxwidth'=>30,'url'=>imageUrl(template_cache(C('sid'),"$name.$i.image")))))}
        </div>
        <div class="col-sm-9">
            <input type="hidden" class="form-control" name="{$name}[{$i}][image]" value="{:template_cache(C('sid'),"$name.$i.image")}"><br/>
            <input type="text" placeholder="幻灯片标题" class="form-control" name="{$name}[{$i}][text]" value="{:template_cache(C('sid'),"$name.$i.text")}"><br/>
            <input type="text" placeholder="幻灯片指向地址" class="form-control" name="{$name}[{$i}][url]" value="{:template_cache(C('sid'),"$name.$i.url")}">
        </div>
    </div>
</div>
<?php endfor; ?>
<?php endif; ?>

<?php // 填写ID ?>
<?php if($vo['type'] === 'image'): ?>
<div class="form-group">
    <label class="col-sm-3 control-label">{$vo.label}</label>
    <div class="col-sm-6">
        <div class="col-sm-3">{:W('Image/upload',array('data'=>array('name'=>$name,'maxwidth'=>30,'url'=>imageUrl(template_cache(C('sid'),"$name.image")))))}</div>
        <div class="col-sm-9">
            <input type="hidden" class="form-control" name="{$name}[image]" value="{:template_cache($name,'image')}"><br/>
            <input type="text" placeholder="图片描述" class="form-control" name="{$name}[text]" value="{:template_cache(C('sid'),"$name.text")}"><br/>
            <input type="text" placeholder="图片扩展数据" class="form-control" name="{$name}[ext]" value="{:template_cache(C('sid'),"$name.ext")}">
        </div>
    </div>
</div>
<?php endif; ?>


<?php endforeach; ?>

</volist>

